<template>
  <details-layout
    :data="data"
    :related="related"
    channel="news"
    titleField="标题"
    dateField="日期"
    contentField="描述">
    <div class="title text-center q-px-lg text-bold">{{data.标题}}</div>
    <div class="info row no-wrap relative-position justify-end">
      <div class="type absolute-center">{{$t('类型')}}: {{data.类型}}</div>
      <div class="date">{{data.日期 | normalDate}}</div>
    </div>
    <div class="details" v-html="data.详情"></div>

    <div v-if="data.链接" class="link q-my-lg q-px-xl full-width text-right">
      <a :href="data.链接" target="_blank">{{$t('查看原文')}}</a>
    </div>
  </details-layout>
</template>

<script>
import mixins from 'eis-admin-mixins';
import { RefreshOnIDChange, RefreshRelatedOnIDChange } from '../../components/mixins/data';
import DetailsLayout from '../../components/detailsLayout.vue';

export default {
  name: 'NewsDetails',
  mixins: [mixins.ObjectDataMixin, RefreshOnIDChange, RefreshRelatedOnIDChange],
  components: {
    DetailsLayout,
  },
  data() {
    return {
      related: [],
    };
  },
  created() {
    this.getRelated();
  },
  methods: {
    getRelated() {
      this.getRequest(`/portal/news/related/${this.$route.params.id}`, { limit: 5 }).then((d) => {
        if (d && d.msg === 'OK') {
          this.related = d.data.docs;
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.link {
  font-size: 16px;
}
</style>
